<?php

namespace App\Http\Controllers\api;

use App\Http\Controllers\Controller;
use App\Repository\RepositoryInterface\ShopInterface;
use Illuminate\Http\Request;

class ShopController extends Controller
{
    protected $shop;

    public function __construct(ShopInterface $shop)
    {
        $this->shop = $shop;
    }

    /**
     * @return mixed
     * 添加评论
     */
    public function shopRemarkAdd()
    {
        //获取数据
        $addData = \request()->post();
        //回调数据
        return $this->shop->shopRemarkAdd($addData);
    }

    /**
     * @return mixed
     * 删除评论
     */
    public function shopRemarkDel()
    {
        //获取id
        $delId = \request()->get('id');
        //执行删除
        return $this->shop->shopRemarkDel($delId);
    }
    public function shopRemarkEdit()
    {
        //获取数据
        $editData = \request()->post();
        //回调数据
        return $this->shop->shopRemarkEdit($editData);
    }
    /**
     * @return mixed
     * 查询评论
     */
    public function shopRemarkSearch()
    {
        //获取数据
        $searchData = \request()->post('searchData');
        //回调数据
        return $this->shop->shopRemarkSearch($searchData);
    }
    /**
     * @return mixed
     * 评论图片上传
     */
    public function remarkImageUpload()
    {
        //获取数据
        $file = \request()->file('file');
        //上传图片
        return $this->shop->remarkImageUpload($file);
    }
    /**
     * @return mixed
     * 全部商品
     */
    public function getShopsAll()
    {
        //查询数据
        return $this->shop->getShopsAll();
    }
    /**
     * @return mixed
     * 商品详情
     */
    public function getShopsDetail()
    {
        //获取商品id
        $id = \request()->get('product_id');
        //查询数据
        return $this->shop->getShopsDetail($id);
    }
    /**
     * @return mixed
     * 商品评论列表
     */
    public function getShopsRemarks()
    {
        //获取商品id
        $id = \request()->get('product_id');
        //查询数据
        return $this->shop->getShopsRemarks($id);
    }
    /**
     * @return mixed
     * 热卖排行榜
     */
    public function list()
    {
        //回调数据
        return $this->shop->list();
    }

    /**
     * @return mixed
     * 首页轮播图
     */
    public function circleImage()
    {
        //回调数据
        return $this->shop->circleImage();
    }

    /**
     * @return mixed
     * es搜索
     */
    public function homeSearch()
    {
        //接受搜索数据
        $search = \request()->post();

        return $this->shop->homeSearch($search);
    }


}
